<template>
    <el-container class="container">
      <el-header class="header" height="300px">
        <div class="accountInfo">
          <div class="userInfo">
            <div class="avatar">
              <el-image :src="avatar"
                        :preview-src-list="[avatar]"
                        style="width: 120px; height: 120px; border-radius: 50%"
              >
              </el-image>
            </div>
            <div class="info">
              <div class="nick"><span>{{currentUser.nick}}</span></div>
              <div class="signature"><span>{{currentUser.signature}}</span></div>
            </div>
          </div>
          <div class="visitor">
            <div style="padding-top: 20px">
              <span>{{currentUser.visitor}}</span>
            </div>
            <div>
              <em>访客量</em>
            </div>
          </div>
        </div>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="消息通知" name="/messageInfo"></el-tab-pane>
          <el-tab-pane label="账号信息" name="/accountInfo"></el-tab-pane>
          <el-tab-pane label="个人信息" name="/personalInfo"></el-tab-pane>
        </el-tabs>
      </el-header>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
</template>

<script>
    export default {
        name: "PersonalCenter",
        data(){
            return{
                currentUser: {},
                noAvatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
            }
        },
        watch: {

        },
        methods:{
          handleClick(tab){
            this.$router.push(tab.name);
          }
        },
        mounted() {
            let user=sessionStorage.getItem("currentUser");
            this.currentUser=JSON.parse(user);
        },
        computed: {
            avatar(){
                return this.currentUser.avatarUrl ? '/api/'+this.currentUser.avatarUrl : this.noAvatar;
            },
            activeName(){
              return this.$route.fullPath;
            }
        }
    }
</script>

<style scoped>
  .container{
    width: 100%;
    height: 100%;
  }
  .header{
    width: 100%;
    background-image: url("../../assets/img/header_bg.png");
    padding: 0 15%;
  }
  .accountInfo{
    display: flex;
    flex-direction: row;
    margin-top: 100px;
  }
  .userInfo{
    display: flex;
    flex-direction: row;
    height: 125px;
  }
  .info{
    margin-left: 20px;
    width: 300px;
  }
  .info .nick{
    font-size: 30px;
    font-weight: bold;
  }
  .info .signature{
    font-size: 14px;
    color: #7f7b7b;
    padding: 10px 0;
    max-height: 65px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .visitor{
    width: 100px;
    height: 125px;
    text-align: center;
    margin-left: 30%;
  }
  .visitor span{
    font-size: 30px;
    font-weight: bold;
  }
  .visitor em{
    font-size: 14px;
    color: #7f7b7b;
    font-style: normal;
  }
  .el-tabs{
    margin-top: 30px;
    padding: 0 3%;
  }
  /deep/ .el-tabs__item{
    font-size: 17px;
  }
  .el-main{
    background-color: #F3F5F9;
    min-height: 600px;
    padding: 0 15%;
  }
</style>
